home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 551-575 / disk_575 / pplib / example.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  2KB  |  74 lines

  1. /*********************************
  2. *                                *
  3. *   powerpacker.library  V35     *
  4. *                                *
  5. *   Release 1.3                  *
  6. *                                *
  7. *   (c) 1991 Nico François       *
  8. *                                *
  9. *   example.c                    *
  10. *                                *
  11. *   This source is public domain *
  12. *   in all respects.             *
  13. *                                *
  14. *********************************/
  15.  
  16. #include <exec/types.h>
  17. #include <exec/memory.h>
  18. #include <libraries/dos.h>
  19. #include <proto/exec.h>
  20. #include <proto/dos.h>
  21.  
  22. #include <stdio.h>
  23.  
  24. #include <proto/powerpacker.h>
  25. #include <libraries/ppbase.h>
  26.  
  27. struct PPBase *PPBase = NULL;
  28.  
  29. UBYTE *filestart = NULL;
  30. ULONG filelen;
  31.  
  32. char file[108] = "testfile";
  33.  
  34. main()
  35. {
  36.    int err;
  37.  
  38.    if (!(PPBase = (struct PPBase *)OpenLibrary ("powerpacker.library", 0L)))
  39.  
  40.       puts ("You need powerpacker.library V33+ !");
  41.  
  42.    else {
  43.  
  44.       puts ("Loading file...");
  45.  
  46.       err = ppLoadData (file, DECR_POINTER, 0L, &filestart, &filelen, NULL);
  47.       if (err)
  48.             printf ("example: %s!\n", ppErrorMessage (err));
  49.  
  50.       else {
  51.  
  52.          puts ("file in memory, using it...");
  53.  
  54.          /* file is loaded at 'filestart' and can now be used */
  55.  
  56.          /* ... */
  57.  
  58.          puts ("done, freeing file...");
  59.  
  60.          }
  61.  
  62.       }
  63.  
  64.    /* free all resources */
  65.  
  66.    if (filestart) FreeMem (filestart, filelen);
  67.  
  68.    if (PPBase) CloseLibrary ((struct Library *)PPBase);
  69.  
  70.    puts ("exiting.");
  71.  
  72.    exit (0);
  73. }
  74.